package com.example.demo.course.controller;

import com.example.demo.course.Course;
import com.example.demo.course.repository.CourseRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/test")
public class TestController {
    @Autowired
    private CourseRepository courseRepository;

    @PostMapping("/addCourse")
    public Course addCourse() {
        Course course = new Course();
        course.setName("线性代数");
        course.setTime("周二 3-4节");
        course.setLocation("教学楼B202");
        course.setTeacher("李教授");
        course.setType("elective");
        return courseRepository.save(course);  // 调用JPA保存
    }
}